package cn.nvrelax.cloudnote.syskit;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 程序描述：系统状态
 * 创建时间：2019/6/3 16:50
 * 编码：nvRelax
 */
@Component
public class SysState {
    @Value("${cn.nvrelax.token.key}")
    private static String encryptKey;
    private static Map<String, Integer> users = new HashMap<>();

    /**
     * 记录系统当前在线的用户
     * @param token
     * @param Id
     * @return
     */
    public static int recordUser(String token,int Id) {
        //Date exp = Jwts.parser().setSigningKey(encryptKey).parseClaimsJws(token).getBody().getExpiration();
        users.put(token,Id);
        return users.size();
    }

    public static Integer[] userIdList() {
        return users.values().toArray(new Integer[0]);
    }
}
